package com.example.camerapush;

import java.util.concurrent.LinkedBlockingDeque;

/**
 * Author:lsh
 * Version: 1.0
 * Description:
 * Date: 2018/2/27
 */

public class Test {
    public static void main(String[] args) throws InterruptedException {
        Test t = new Test();
        for (int i=0;i<10;i++) {
            t.queue.add(i);
//            Thread.sleep(1000);
        }
        t.aa();
    }

    LinkedBlockingDeque<Integer> queue = new LinkedBlockingDeque<>();

    public void aa() {
        new Thread(new Runnable() {
            @Override
            public void run() {
                while (true) {
                    try {
                        Integer poll = queue.take();
                        Thread.sleep(5000);
                        if (poll == 5) queue.clear();
                        System.out.println(poll);
                        System.out.println(queue.size()+"queueSize");
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }

            }
        }).start();


    }
}
